package com.tuda.system.mapper;

import java.util.Date;
import java.util.List;

import com.tuda.system.domain.TudaVerificationCode;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 验证码Mapper接口
 * 
 * @author Ys
 * @date 2023-07-13
 */
public interface TudaVerificationCodeMapper
{

    @Select("SELECT * FROM tuda_verification_code WHERE code=#{code} AND phone=#{phone} AND type=#{type} AND used=0 AND invalid_time >= NOW()")
    TudaVerificationCode queryByInfo(@Param("code") String code, @Param("phone") String phone, @Param("type") Integer type);

    @Select("SELECT * FROM tuda_verification_code WHERE phone=#{phone} AND DATE_FORMAT(create_time,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d')")
    List<TudaVerificationCode> selectListByInfo(@Param("phone") String phone);

    /**
     * 查询验证码
     * 
     * @param id 验证码主键
     * @return 验证码
     */
    TudaVerificationCode selectTudaVerificationCodeById(Long id);

    /**
     * 查询验证码列表
     * 
     * @param tudaVerificationCode 验证码
     * @return 验证码集合
     */
    List<TudaVerificationCode> selectTudaVerificationCodeList(TudaVerificationCode tudaVerificationCode);

    /**
     * 新增验证码
     * 
     * @param tudaVerificationCode 验证码
     * @return 结果
     */
    int insertTudaVerificationCode(TudaVerificationCode tudaVerificationCode);

    /**
     * 修改验证码
     * 
     * @param tudaVerificationCode 验证码
     * @return 结果
     */
    int updateTudaVerificationCode(TudaVerificationCode tudaVerificationCode);

    /**
     * 删除验证码
     * 
     * @param id 验证码主键
     * @return 结果
     */
    int deleteTudaVerificationCodeById(Long id);

    /**
     * 批量删除验证码
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteTudaVerificationCodeByIds(String[] ids);
}
